if (ActiveDocument.ViewType == viewWYSIWYG || ActiveDocument.ViewType == viewTagsOn) {
Do_MakeReadOnlySection();
}
]]></MACRO>
<MACRO name="Save As Template" lang="JScript" id="90"><![CDATA[
var obj = new ActiveXObject("HMExtras.FileDlg");
var filter = "Web Page Template (*.htm, *.html)|*.htm;*.html|All Files (*.*)|*.*||";
if (obj.DisplayFileDlg(0, "File Save As", filter, Application.Path + "\\Template")) {
ActiveDocument.SaveAs(obj.FullPathName, true); // save and put on recent file list
}
]]></MACRO>
<MACRO name="MakeReplaceText" key="Ctrl+Alt+Z" lang="JScript" id="62" tooltip="Make Replace Text (Ctrl+Alt+Z)" desc="Makes current selection into replaceable text"><![CDATA[
function Do_MakeReplaceText() {
// Check if we are in a view that works
var view = Application.ActiveDocument.ViewType;
if (view != viewWYSIWYG && view != viewTagsOn) {
var msg = "Can't make replaceable text in this view.";
msg += "\nPlease switch to Tags On or WYSIWYG view and try again.";
Application.Alert(msg);
return;
}
// Check if we have an extended selection
if (Selection.IsInsertionPoint) {
Application.Alert("Select some text and try again.");
return;
}
// Handle replace text that is alread there in the selection
// This is not perfect: if there are other PI's it will fail.
// But it should be plenty good enough for HTML.
var txt = Selection.Text;
var exp = new RegExp("<\\?xm-replace_text ", "g");
txt = txt.replace(exp, "");
exp.compile("\\?>", "g");
txt = txt.replace(exp, "");
Selection.InsertReplaceableText(txt);
}
Do_MakeReplaceText(); // Put it into a function for easier error handling